package com.decent.ejfadmin.config;

import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.web.servlet.SimpleCookie;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author weicx
 * @date 2019/04/11
 */
@Configuration
public class SessionManagerConfig {
    @Autowired
    private SessionManager sessionManager;
    @Autowired
    private SimpleCookie simpleCookie;

    @PostConstruct
    public void init() {
        DefaultWebSessionManager sessionManager = (DefaultWebSessionManager) this.sessionManager;
        sessionManager.setSessionIdCookieEnabled(true);
        sessionManager.setSessionIdCookie(simpleCookie);
    }
}
